﻿@using RuoVea.ExDto
@using RuoVea.OmiLog.Language
@using RuoVea.OmiLog.Attributes
@using RuoVea.OmiLog.Options
@{
    AppConfig config = ConfigManages.Config ?? new AppConfig();
}
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@Html.Raw(i18n.exception_log)</title>
    <link href="~/ruoveaui/xg6rvft8p/avue/index.css" rel="stylesheet" />
    <link href="~/ruoveaui/xg6rvft8p/elementui/index.min.css" rel="stylesheet" />
    <style>.el-button [class*="el-icon-"] + span {margin-left: 1px !important;}</style>
    <script src="~/ruoveaui/xg6rvft8p/avue/filesaver.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/xlsx.full.min.js"></script>
</head>
<body>
    <div id="app" v-cloak>
        <avue-crud :data="tableData" :option="option" :page.sync="pageOption" :table-loading="loading"
                   v-on:refresh-change="refreshChange"
                   v-on:search-change="searchChange"
                   v-on:search-reset="resetChange"
                   v-on:on-load="onLoad">
            <template slot="avatar" slot-scope="scope">
                <el-avatar shape="circle" :src="scope.row.avatar">{{scope.row.account}} </el-avatar>
            </template>

            <template slot="record" slot-scope="scope">
                <modify-record :data="scope.row"></modify-record>
            </template>
             <template slot="menuRight" slot-scope="{size}">
                <el-button icon="el-icon-delete" type="danger" circle :size="size" v-on:click="handleDeleteAll" v-if="option.clearBtn"></el-button>
              </template>
        </avue-crud>
    </div>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.i18n.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.lang.js"></script>
    <script>
        Vue.prototype.i18n.messages.zhCN = { ...Vue.prototype.i18n.messages.zhCN, ...{ "method_name": "方法名", "class_name": "类名", "exception_message": "异常信息", "exception_source": "异常源", "stack_trace": "堆栈信息", "parameter_object": "参数对象", "exception_time": "异常时间", "operator": "操作人"} };         
        Vue.prototype.i18n.messages.en = { ...Vue.prototype.i18n.messages.en, ...{"method_name": "Method Name", "class_name": "Class Name", "exception_message": "Exception Message", "exception_source": "Exception Source", "stack_trace": "Stack Trace", "parameter_object": "Parameter Object", "exception_time": "Exception Time", "operator": "Operator" } };         
        Vue.prototype.i18n.messages.fr = { ...Vue.prototype.i18n.messages.fr, ...{"method_name": "Nom de méthode", "class_name": "Nom de classe", "exception_message": "Message d'exception", "exception_source": "Source de l'exception", "stack_trace": "Informations de pile", "parameter_object": "Objet de paramètre", "exception_time": "Heure de l'exception", "operator": "Opérateur" } };         
        Vue.prototype.i18n.messages.ja = { ...Vue.prototype.i18n.messages.ja, ...{ "method_name": "メソッド名", "class_name": "クラス名", "exception_message": "例外メッセージ", "exception_source": "例外のソース", "stack_trace": "スタックトレース", "parameter_object": "パラメータオブジェクト", "exception_time": "例外時間", "operator": "操作者"} };         
        Vue.prototype.i18n.messages.vi = { ...Vue.prototype.i18n.messages.vi, ...{ "method_name": "Tên phương thức", "class_name": "Tên lớp", "exception_message": "Thông tin ngoại lệ", "exception_source": "Nguồn ngoại lệ", "stack_trace": "Thông tin ngăn xếp", "parameter_object": "Đối tượng tham số", "exception_time": "Thời gian ngoại lệ", "operator": "Người thực hiện"} };         
        Vue.prototype.i18n.messages.zhTW = { ...Vue.prototype.i18n.messages.zhTW, ...{ "method_name": "方法名", "class_name": "类名", "exception_message": "异常信息", "exception_source": "异常源", "stack_trace": "堆栈信息", "parameter_object": "参数对象", "exception_time": "异常时间", "operator": "操作人"} };
    </script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhCN.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/en.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/fr.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/ja.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/vi.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhTW.js"></script>
    <script>Vue.prototype.$baseURL = "@config?.PrefixRoute";</script>
    <script src="~/ruoveaui/xg6rvft8p/vue/axios.min.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue-i18n.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.option.js"></script>
    <script>

        new Vue({
            el: '#app',
            data() {
                return {
                    name: "logex",
                    pageUrl: "/logex/pages", 

                    pageOption: {
                    total: 0,
                    page: 1,
                    pageSize: 10
            },
            
            loading: true,
            btnLoading: false,
            tableData: [],
            searchParams: {}, 

            searchShowBtn: false,
            refreshBtn: false,
            option: {
                searchShowBtn: Permissions.avePermission(`sysLogEx:pages`),
                refreshBtn: Permissions.avePermission(`sysLogEx:pages`),
                clearBtn: Permissions.avePermission(`sysLogEx:clear`),
                rowKey: 'id',
                columnBtn: false,
                searchShow: false,
                addBtn:false,
                menu:false,
                editBtn:false,
                delBtn:false,
                viewBtn:false,
                excelBtn:Permissions.avePermission(`sysLogEx:export`),
                column: [
                    { prop: "id", label: `${this.i18n.t('primary_key')}`, search: false, hide: true, type: "number", display: false, showColumn: false, },

                    { prop: "methodName", label: `${this.i18n.t('method_name')}`, search: true, hide: false, type: "input",width:180, },
                    { prop: "className", label: `${this.i18n.t('class_name')}`, search: true, hide: false, type: "input",width:220, },
                    { prop: "exceptionMsg", label: `${this.i18n.t('exception_message')}`, search: true, hide: false, type: "input",overHidden:true, },
                    { prop: "exceptionSource", label: `${this.i18n.t('exception_source')}`, search: false, hide: false, type: "input", overHidden:true,},
                    { prop: "stackTrace", label: `${this.i18n.t('stack_trace')}`, search: false, hide: false, type: "input", overHidden:true,},
                    { prop: "paramsObj", label: `${this.i18n.t('parameter_object')}`, search: false, hide: false, type: "input", overHidden:true,},
                    { prop: "exceptionTime", label: `${this.i18n.t('exception_time')}`, search: true, hide: false, type: "datetime",searchRange: true,width:180, },
                    { prop: "name", label: `${this.i18n.t('operator')}`, search: true, hide: false, type: "input",overHidden:true, },
                ]
            }
                }
            },
            created() {
            },
            methods: {
                 hasPermission(key) {
                if (key === 'columnBtn' || key === 'menu' || key === 'refreshBtn') return true;
                else return Permissions.avePermission(`${this.name}:${key}`);
            },
            getPermission(key) {
                return Permissions.avePermission(`${key}`);
            },
            onLoad(page, done) {
                if (this.searchParams.exceptionTime) {
                    const [BeginTime, EndTime] = this.searchParams.exceptionTime
                    var data = { ...page, ...this.searchParams };
                    data.BeginTime = BeginTime;
                    data.EndTime = EndTime;
                }
                else {
                    var data = { ...page, ...this.searchParams };
                }
                this.$http.post(`${this.pageUrl}`, data).then((res) => {
                    this.tableData = res.rows;
                    this.pageOption.total = res.totalRows;
                    this.loading = false;
                    if (done) { done(); }
                }).catch(e => {
                    this.loading = false;
                    console.log(e);
                });
            },
            searchChange(params, done) {
                this.searchParams = params;
                this.pageOption.page = 1;
                this.onLoad(this.pageOption, done);
            },
            resetChange(item) {
                this.searchParams = item;
                this.pageOption.page = 1;
                this.onLoad(this.pageOption);
            },
            refreshChange() { this.onLoad(this.pageOption); },
            
            handleDeleteAll() {
                    this.$confirm(this.i18n.t('confirmdelete'), this.i18n.t('tips'), { confirmButtonText: this.i18n.t('determine'), cancelButtonText: this.i18n.t('cancel'), type: 'error', customClass: "elmessagebox" }).then(() => {
                        this.$http.post("/logdiff/clear").then((res) => {
                            if (!res) {
                                this.$message({ message:`${this.i18n.t('submit_success')}`, center: true, type: 'success' });
                                this.onLoad();
                            }
                        });
                    }).catch(_ => { console.info(_); })
                },
            }
        });
    </script>
</body>
</html>